<template>
  <div class="page-container">
    <!-- 顶部标题栏 -->
    <header class="view-header">
      <el-page-header content="查看详情" @back="$router.back()" />
    </header>
    <main v-if="cardDetails.carInfoId" class="view-main">
      <!-- 表单容器1 -->
      <div class="tabel-container">
        <!-- 标题 -->
        <div class="title">车辆信息：</div>
        <div class="tabel">
          <!-- 车辆信息列表 -->
          <el-descriptions class="margin-top" :column="2" size="medium" :label-style="{ color: '#333', fontWeight: 'bold' }">
            <el-descriptions-item label="车主姓名">{{ cardDetails.personName }}</el-descriptions-item>
            <el-descriptions-item label="联系方式">{{ cardDetails.phoneNumber }}</el-descriptions-item>
            <el-descriptions-item label="车牌号码">{{ cardDetails.carNumber }}</el-descriptions-item>
            <el-descriptions-item label="车辆品牌">{{ cardDetails.carBrand }}</el-descriptions-item>
          </el-descriptions>
        </div>
      </div>
      <!-- 表单容器2 -->
      <div class="tabel-container">
        <!-- 标题 -->
        <div class="title">最新一次月卡缴费信息：</div>
        <!-- 最新一次月卡信息表单 -->
        <div class="tabel">
          <el-table :data="cardDetails.rechargeList" border :header-cell-style="{ background: '#f7f8f9', color: '#333', fontWeight: 'bold' }">
            <el-table-column type="index" label="序号" width="80" />
            <el-table-column label="有效时间" width="220">
              <template #default="{ row }">
                {{ `${row.cardStartDate} 至 ${row.cardEndDate}` }}
              </template>
            </el-table-column>
            <el-table-column label="支付金额" prop="paymentAmount" />
            <el-table-column label="支付方式" prop="paymentMethod" />
            <el-table-column label="办理时间" prop="createTime" width="180" />
            <el-table-column label="办理人" prop="createUser" />
          </el-table>
        </div>
      </div>
    </main>
  </div>
</template>

<script>
import { getCardInfoAPI } from '@/api/car/carcard'
export default {
  name: 'AddCard',
  data() {
    return {
      // 车辆信息表单数据
      cardDetails: {}
    }
  },
  computed: {
    cardId() {
      return this.$route.query.id
    }
  },
  async created() {
    if (this.cardId) {
      // 获取月卡信息详情
      await this.getCardInfo()
    }
  },
  methods: {
    // 获取月卡信息详情
    async getCardInfo() {
      const res = await getCardInfoAPI(this.cardId)
      console.log(res)
      this.cardDetails = res
    }
  }
}
</script>

<style scoped lang="scss">
.page-container {
  .view-header {
    display: flex;
    align-items: center;
    padding: 0 20px;
    margin-bottom: 30px;
    height: 64px;
    background-color: #fff;
    border-bottom: 1px solid #eee;

    ::v-deep .el-page-header {
      .el-page-header__title {
        font-size: 16px;
        font-weight: 600;
        color: #444;
      }

      .el-page-header__content {
        font-size: 16px;
        font-weight: 600;
        color: #444;
      }
    }
  }

  .view-main {
    padding-left: 50px;

    .tabel-container {
      background-color: #fff;

      .title {
        height: 60px;
        line-height: 60px;
        font-weight: 600;
        color: #444;
      }

      .tabel {
        margin-bottom: 20px;
        padding: 20px 65px 24px;
      }
    }
  }

  .view-footer {
    width: 100%;
    padding: 20px 0 0 270px;
    color: #000000d9;
    font-size: 14px;
    background: #fff;

    .reset-btn {
      margin-left: 30px;
    }
  }
}
</style>
